
<template>
  <div>
    <!--搜索框-->
    <el-form
      ref="mqExecuteFormRef"
      :model="mqExecuteForm"
      :inline="true"
      size="small"
    >
      <el-form-item label="运行状态">
        <el-select
          v-model="mqExecuteForm.status"
          placeholder="请选择运行状态"
        >
          <el-option
            v-for="item in mqExecuteForm.statusOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="selectList">查询</el-button>
      </el-form-item>
    </el-form>
    <!--表单-->
    <el-table
      v-loading="loading"
      :data="tableData"
      border
      style="width: 100%"
      size="small"
    >
      <!--表单展示--->
      <el-table-column prop="startTime" label="开始时间" />
      <el-table-column prop="endTime" label="结束时间" />
      <el-table-column prop="executeInterval" label="执行间隔时间(毫秒)" />
      <el-table-column label="运行状态">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.status == 0">success</el-tag>
          <el-tag type="error" v-if="scope.row.status == 1">error</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="remark" label="备注" />
    </el-table>
    <!--分页操作-->
    <el-pagination
      layout="total, sizes, prev, pager, next, jumper"
      :page-sizes="pageSizes"
      :total="total"
      :current-page.sync="pageNo"
      :page-size.sync="pageSize"
      @current-change="selectList"
      @size-change="selectList"
    />
  </div>
</template>

<script>
import { mqExecuteList } from "@/api/tool/dev/mqexecute";
import { Message } from "element-ui";

export default {
  data() {
    return {
      mqExecuteForm: {
        status: -1,
        jobType:-1,
        mqId: 0,
        statusOptions: [
          {
            value: -1,
            label: "请选择",
          },
          {
            value: 0,
            label: "成功",
          },
          {
            value: 1,
            label: "异常",
          },
        ],
        pageSize: 1,
        pageNum: 10,
      },
      tableData: [],
      btnLoad: false,
      loading: false,
      pageSizes: [5, 10, 20, 30, 50],
      pageSize: 10,
      pageNo: 1,
      total: 0,
    };
  },
  mounted() {
    this.mqExecuteForm.mqId = this.$route.query.id;
    this.selectList();
  },
  methods: {
    // 初始化数据
    selectList() {
      this.loading = true;
      this.tableData = [];
      const params = {
        pageNum: this.pageNo,
        pageSize: this.pageSize,
        status: this.mqExecuteForm.status,
        mqId: this.mqExecuteForm.mqId
      };
      mqExecuteList(params)
        .then((response) => {
          this.tableData = response.data.rows;
          this.total = response.data.total;
          this.loading = false;
        })
        .catch(() => {
          this.loading = false;
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.operationIcon {
  margin-left: 10px;
}
</style>
